﻿// $ PURE $ // class name and mean

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ScintillaNET;
using System.Drawing;

namespace CodeTable
{
    class BlockRender : BlockAutosize
    {
        public BlockRender(string name, Scintilla prototype, Color backColor) : base(name, prototype)
        {
            this.BackColor = backColor;
            this.Markers[0].Symbol = ScintillaNET.MarkerSymbol.Background; // HACK !!!
            this.Markers[0].BackColor = backColor; // HACK !!!
        }

        private void SetHackMarkersBackColor()
        {
            foreach (ScintillaNET.Line line in this.Lines)
            {
                line.AddMarker(0);
            }
        }

        public Bitmap GetCodeImage(string codeText)
        {
            this.Text = codeText;
            SetHackMarkersBackColor(); // HACK !!! to set background color. // TODO: use style in proper way
            Bitmap bitmapBuffer = new Bitmap(this.Width, this.Height);
            this.DrawToBitmap(bitmapBuffer, new Rectangle(0, 0, this.Width, this.Height));
            return bitmapBuffer;
        }
    }
}
